<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang='en' xml:lang='en' xmlns='http://www.w3.org/1999/xhtml'>
  <head>
    <title>/Users/pbartels/.rvm/gems/ruby-1.9.2-p136/gems/rcov-0.9.9/lib/rcov/code_coverage_analyzer.rb</title>
    <link href="screen.css" media="all" rel="stylesheet" type="text/css" />
    <link href="print.css" media="print" rel="stylesheet" type="text/css" />
    
    <meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
    <script type="text/javascript" src="rcov.js"></script>
  </head>
  <body>
    <h1>Spec C0 Coverage Information - RCov</h1>
    <h2>/Users/pbartels/.rvm/gems/ruby-1.9.2-p136/gems/rcov-0.9.9/lib/rcov/code_coverage_analyzer.rb</h2>

    

    <div class="report_table_wrapper">
      <table class='report' id='report_table'>
        <thead>
          <tr>
            <th class="left_align">Name</th>
            <th class="right_align">Total Lines</th>
            <th class="right_align">Lines of Code</th>
            <th class="left_align">Total Coverage</th>
            <th class="left_align">Code Coverage</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td class="left_align"><a href="-Users-pbartels-_rvm-gems-ruby-1_9_2-p136-gems-rcov-0_9_9-lib-rcov-code_coverage_analyzer_rb.html">/Users/pbartels/.rvm/gems/ruby-1.9.2-p136/gems/rcov-0.9.9/lib/rcov/code_coverage_analyzer.rb</a></td>
            <td class='right_align'><tt>271</tt></td>
            <td class='right_align'><tt>156</tt></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>2.95%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:3px"></div>
            <div class="uncovered" style="width:97px"></div>
          </div></td>
            <td class="left_align"><div class="percent_graph_legend"><tt class=''>2.56%</tt></div>
          <div class="percent_graph">
            <div class="covered" style="width:3px"></div>
            <div class="uncovered" style="width:97px"></div>
          </div></td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <h3>Key</h3>
    
    <div class="key"><pre><span class='marked'>Code reported as executed by Ruby looks like this...</span><span class='marked1'>and this: this line is also marked as covered.</span><span class='inferred'>Lines considered as run by rcov, but not reported by Ruby, look like this,</span><span class='inferred1'>and this: these lines were inferred by rcov (using simple heuristics).</span><span class='uncovered'>Finally, here's a line marked as not executed.</span></pre></div>

    <h3>Coverage Details</h3>

    <table class="details">
      <tbody>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line1">1</a> module Rcov</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line2">2</a>   # A CodeCoverageAnalyzer is responsible for tracing code execution and</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line3">3</a>   # returning code coverage and execution count information.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line4">4</a>   #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line5">5</a>   # Note that you must &lt;tt&gt;require 'rcov'&lt;/tt&gt; before the code you want to</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line6">6</a>   # analyze is parsed (i.e. before it gets loaded or required). You can do that</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line7">7</a>   # by either invoking ruby with the &lt;tt&gt;-rrcov&lt;/tt&gt; command-line option or</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line8">8</a>   # just:</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line9">9</a>   #  require 'rcov'</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line10">10</a>   #  require 'mycode'</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line11">11</a>   #  # ....</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line12">12</a>   #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line13">13</a>   # == Example</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line14">14</a>   #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line15">15</a>   #  analyzer = Rcov::CodeCoverageAnalyzer.new</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line16">16</a>   #  analyzer.run_hooked do </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line17">17</a>   #    do_foo  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line18">18</a>   #    # all the code executed as a result of this method call is traced</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line19">19</a>   #  end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line20">20</a>   #  # ....</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line21">21</a>   #  </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line22">22</a>   #  analyzer.run_hooked do </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line23">23</a>   #    do_bar</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line24">24</a>   #    # the code coverage information generated in this run is aggregated</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line25">25</a>   #    # to the previously recorded one</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line26">26</a>   #  end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line27">27</a>   #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line28">28</a>   #  analyzer.analyzed_files   # =&gt; [&quot;foo.rb&quot;, &quot;bar.rb&quot;, ... ]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line29">29</a>   #  lines, marked_info, count_info = analyzer.data(&quot;foo.rb&quot;)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line30">30</a>   #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line31">31</a>   # In this example, two pieces of code are monitored, and the data generated in</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line32">32</a>   # both runs are aggregated. +lines+ is an array of strings representing the </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line33">33</a>   # source code of &lt;tt&gt;foo.rb&lt;/tt&gt;. +marked_info+ is an array holding false,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line34">34</a>   # true values indicating whether the corresponding lines of code were reported</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line35">35</a>   # as executed by Ruby. +count_info+ is an array of integers representing how</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line36">36</a>   # many times each line of code has been executed (more precisely, how many</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line37">37</a>   # events where reported by Ruby --- a single line might correspond to several</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line38">38</a>   # events, e.g. many method calls).</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line39">39</a>   #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line40">40</a>   # You can have several CodeCoverageAnalyzer objects at a time, and it is</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line41">41</a>   # possible to nest the #run_hooked / #install_hook/#remove_hook blocks: each</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line42">42</a>   # analyzer will manage its data separately. Note however that no special</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line43">43</a>   # provision is taken to ignore code executed &quot;inside&quot; the CodeCoverageAnalyzer</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line44">44</a>   # class. At any rate this will not pose a problem since it's easy to ignore it</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line45">45</a>   # manually: just don't do</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line46">46</a>   #   lines, coverage, counts = analyzer.data(&quot;/path/to/lib/rcov.rb&quot;)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line47">47</a>   # if you're not interested in that information.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line48">48</a>   class CodeCoverageAnalyzer &lt; DifferentialAnalyzer</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line49">49</a>     @hook_level = 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line50">50</a>     # defined this way instead of attr_accessor so that it's covered</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line51">51</a>     def self.hook_level      # :nodoc:</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line52">52</a>       @hook_level </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line53">53</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line54">54</a>      </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line55">55</a>     def self.hook_level=(x)  # :nodoc: </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line56">56</a>       @hook_level = x </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line57">57</a>     end </pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line58">58</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line59">59</a>     def initialize</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line60">60</a>       @script_lines__ = SCRIPT_LINES__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line61">61</a>       super(:install_coverage_hook, :remove_coverage_hook,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line62">62</a>             :reset_coverage)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line63">63</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line64">64</a>   </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line65">65</a>     # Return an array with the names of the files whose code was executed inside</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line66">66</a>     # the block given to #run_hooked or between #install_hook and #remove_hook.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line67">67</a>     def analyzed_files</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line68">68</a>       update_script_lines__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line69">69</a>       raw_data_relative.select do |file, lines|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line70">70</a>         @script_lines__.has_key?(file)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line71">71</a>       end.map{|fname,| fname}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line72">72</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line73">73</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line74">74</a>     # Return the available data about the requested file, or nil if none of its</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line75">75</a>     # code was executed or it cannot be found.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line76">76</a>     # The return value is an array with three elements:</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line77">77</a>     #  lines, marked_info, count_info = analyzer.data(&quot;foo.rb&quot;)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line78">78</a>     # +lines+ is an array of strings representing the </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line79">79</a>     # source code of &lt;tt&gt;foo.rb&lt;/tt&gt;. +marked_info+ is an array holding false,</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line80">80</a>     # true values indicating whether the corresponding lines of code were reported</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line81">81</a>     # as executed by Ruby. +count_info+ is an array of integers representing how</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line82">82</a>     # many times each line of code has been executed (more precisely, how many</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line83">83</a>     # events where reported by Ruby --- a single line might correspond to several</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line84">84</a>     # events, e.g. many method calls).</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line85">85</a>     #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line86">86</a>     # The returned data corresponds to the aggregation of all the statistics</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line87">87</a>     # collected in each #run_hooked or #install_hook/#remove_hook runs. You can</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line88">88</a>     # reset the data at any time with #reset to start from scratch.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line89">89</a>     def data(filename)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line90">90</a>       raw_data = raw_data_relative</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line91">91</a>       update_script_lines__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line92">92</a>       unless @script_lines__.has_key?(filename) &amp;&amp; </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line93">93</a>              raw_data.has_key?(filename)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line94">94</a>         return nil </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line95">95</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line96">96</a>       refine_coverage_info(@script_lines__[filename], raw_data[filename])</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line97">97</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line98">98</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line99">99</a>     # Data for the first file matching the given regexp.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line100">100</a>     # See #data.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line101">101</a>     def data_matching(filename_re)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line102">102</a>       raw_data = raw_data_relative</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line103">103</a>       update_script_lines__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line104">104</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line105">105</a>       match = raw_data.keys.sort.grep(filename_re).first</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line106">106</a>       return nil unless match</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line107">107</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line108">108</a>       refine_coverage_info(@script_lines__[match], raw_data[match])</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line109">109</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line110">110</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line111">111</a>     # Execute the code in the given block, monitoring it in order to gather</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line112">112</a>     # information about which code was executed.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line113">113</a>     def run_hooked; super end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line114">114</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line115">115</a>     # Start monitoring execution to gather code coverage and execution count</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line116">116</a>     # information. Such data will be collected until #remove_hook is called.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line117">117</a>     #</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line118">118</a>     # Use #run_hooked instead if possible.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line119">119</a>     def install_hook; super end</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line120">120</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line121">121</a>     # Stop collecting code coverage and execution count information.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line122">122</a>     # #remove_hook will also stop collecting info if it is run inside a</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line123">123</a>     # #run_hooked block.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line124">124</a>     def remove_hook; super end</pre></td>
          </tr>
        
          
          
          <tr class="marked">
            <td><pre><a name="line125">125</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line126">126</a>     # Remove the data collected so far. The coverage and execution count</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line127">127</a>     # &quot;history&quot; will be erased, and further collection will start from scratch:</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line128">128</a>     # no code is considered executed, and therefore all execution counts are 0.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line129">129</a>     # Right after #reset, #analyzed_files will return an empty array, and</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line130">130</a>     # #data(filename) will return nil.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line131">131</a>     def reset; super end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line132">132</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line133">133</a>     def dump_coverage_info(formatters) # :nodoc:</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line134">134</a>       update_script_lines__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line135">135</a>       raw_data_relative.each do |file, lines|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line136">136</a>         next if @script_lines__.has_key?(file) == false</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line137">137</a>         lines = @script_lines__[file]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line138">138</a>         raw_coverage_array = raw_data_relative[file]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line139">139</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line140">140</a>         line_info, marked_info, </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line141">141</a>           count_info = refine_coverage_info(lines, raw_coverage_array)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line142">142</a>         formatters.each do |formatter|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line143">143</a>           formatter.add_file(file, line_info, marked_info, count_info)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line144">144</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line145">145</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line146">146</a>       formatters.each{|formatter| formatter.execute}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line147">147</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line148">148</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line149">149</a>     private</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line150">150</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line151">151</a>     def data_default; {} end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line152">152</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line153">153</a>     def raw_data_absolute</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line154">154</a>       Rcov::RCOV__.generate_coverage_info</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line155">155</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line156">156</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line157">157</a>     def aggregate_data(aggregated_data, delta)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line158">158</a>       delta.each_pair do |file, cov_arr|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line159">159</a>         dest = (aggregated_data[file] ||= Array.new(cov_arr.size, 0))</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line160">160</a>         cov_arr.each_with_index do |x,i| </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line161">161</a>           dest[i] ||= 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line162">162</a>           dest[i] += x.to_i</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line163">163</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line164">164</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line165">165</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line166">166</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line167">167</a>     def compute_raw_data_difference(first, last)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line168">168</a>       difference = {}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line169">169</a>       last.each_pair do |fname, cov_arr|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line170">170</a>         unless first.has_key?(fname)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line171">171</a>           difference[fname] = cov_arr.clone</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line172">172</a>         else</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line173">173</a>           orig_arr = first[fname]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line174">174</a>           diff_arr = Array.new(cov_arr.size, 0)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line175">175</a>           changed = false</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line176">176</a>           cov_arr.each_with_index do |x, i|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line177">177</a>             diff_arr[i] = diff = (x || 0) - (orig_arr[i] || 0)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line178">178</a>             changed = true if diff != 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line179">179</a>           end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line180">180</a>           difference[fname] = diff_arr if changed</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line181">181</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line182">182</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line183">183</a>       difference</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line184">184</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line185">185</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line186">186</a>     def refine_coverage_info(lines, covers)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line187">187</a>       marked_info = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line188">188</a>       count_info = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line189">189</a>       lines.size.times do |i|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line190">190</a>         c = covers[i]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line191">191</a>         marked_info &lt;&lt; ((c &amp;&amp; c &gt; 0) ? true : false)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line192">192</a>         count_info &lt;&lt; (c || 0)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line193">193</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line194">194</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line195">195</a>       script_lines_workaround(lines, marked_info, count_info)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line196">196</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line197">197</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line198">198</a>     # Try to detect repeated data, based on observed repetitions in line_info:</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line199">199</a>     # this is a workaround for SCRIPT_LINES__[filename] including as many copies</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line200">200</a>     # of the file as the number of times it was parsed.</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line201">201</a>     def script_lines_workaround(line_info, coverage_info, count_info)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line202">202</a>       is_repeated = lambda do |div|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line203">203</a>         n = line_info.size / div</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line204">204</a>         break false unless line_info.size % div == 0 &amp;&amp; n &gt; 1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line205">205</a>         different = false</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line206">206</a>         n.times do |i|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line207">207</a>         </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line208">208</a>           things = (0...div).map { |j| line_info[i + j * n] }</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line209">209</a>           if things.uniq.size != 1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line210">210</a>             different = true</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line211">211</a>             break</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line212">212</a>           end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line213">213</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line214">214</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line215">215</a>         ! different</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line216">216</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line217">217</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line218">218</a>       factors = braindead_factorize(line_info.size)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line219">219</a>       factors.each do |n|</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line220">220</a>         if is_repeated[n]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line221">221</a>           line_info = line_info[0, line_info.size / n]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line222">222</a>           coverage_info = coverage_info[0, coverage_info.size / n]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line223">223</a>           count_info = count_info[0, count_info.size / n]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line224">224</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line225">225</a>       end if factors.size &gt; 1   # don't even try if it's prime</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line226">226</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line227">227</a>       [line_info, coverage_info, count_info]</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line228">228</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line229">229</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line230">230</a>     def braindead_factorize(num)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line231">231</a>       return [0] if num == 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line232">232</a>       return [-1] + braindead_factorize(-num) if num &lt; 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line233">233</a>       factors = []</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line234">234</a>       while num % 2 == 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line235">235</a>         factors &lt;&lt; 2</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line236">236</a>         num /= 2</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line237">237</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line238">238</a>       size = num</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line239">239</a>       n = 3</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line240">240</a>       max = Math.sqrt(num)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line241">241</a>       while n &lt;= max &amp;&amp; n &lt;= size</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line242">242</a>         while size % n == 0</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line243">243</a>           size /= n</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line244">244</a>           factors &lt;&lt; n</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line245">245</a>         end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line246">246</a>         n += 2</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line247">247</a>       end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line248">248</a>       factors &lt;&lt; size if size != 1</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line249">249</a>       factors</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line250">250</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line251">251</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line252">252</a>     def update_script_lines__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line253">253</a>       @script_lines__ = @script_lines__.merge(SCRIPT_LINES__)</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line254">254</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line255">255</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line256">256</a>     public</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line257">257</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line258">258</a>     def marshal_dump # :nodoc:</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line259">259</a>       # @script_lines__ is updated just before serialization so as to avoid</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line260">260</a>       # missing files in SCRIPT_LINES__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line261">261</a>       ivs = {}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line262">262</a>       update_script_lines__</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line263">263</a>       instance_variables.each{|iv| ivs[iv] = instance_variable_get(iv)}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line264">264</a>       ivs</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line265">265</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line266">266</a> </pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line267">267</a>     def marshal_load(ivs) # :nodoc:</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line268">268</a>       ivs.each_pair{|iv, val| instance_variable_set(iv, val)}</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line269">269</a>     end</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line270">270</a>   end # CodeCoverageAnalyzer</pre></td>
          </tr>
        
          
          
          <tr class="uncovered">
            <td><pre><a name="line271">271</a> end</pre></td>
          </tr>
        
      </tbody>
    </table>

    <p>Generated on 2011-07-06 14:13:20 +1200 with <a href="http://github.com/relevance/rcov">rcov 0.9.8</a></p>

  </body>
</html>
